package casa.depesos.app.com.http.req;

import android.os.Build;
import android.text.TextUtils;


import java.util.Map;

import casa.depesos.app.com.BuildConfig;
import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.GetCodeBean;
import casa.depesos.app.com.http.parser.GetCodeParser;
import casa.depesos.app.com.utils.Constant;
import casa.depesos.app.com.utils.Utils;

public class ReportReq implements HttpReq<GetCodeBean> {
    String orderId, contentId;
    boolean isShow;
    long inTime, outTime;

    public ReportReq(String action, boolean isShow, boolean isExit) {
        contentId = action;
        this.isShow = isShow;
        if (isShow) {
            inTime = System.currentTimeMillis();
        }
        if (isExit) {
            outTime = System.currentTimeMillis();
        }
    }

    @Override
    public void req(ReqCallback<GetCodeBean> callback) {//  addUserBehavior
        req("/app/consumer/logUserAction", new GetCodeParser(false), callback);
    }

    @Override
    public Map getBody() {
        Map map = HttpReq.super.getBody();
        if (!TextUtils.isEmpty(orderId)) {
            map.put("orderID", orderId);
        }
        map.put("contentID", contentId);
        map.put("typeCategory", 1);
        map.put("reaType", isShow ? 1 : 2);
        map.put("deviceID", Utils.getDeviceId());
        map.put("veNm", BuildConfig.VERSION_CODE);
        map.put("reportTimeRecord", System.currentTimeMillis());
        if (inTime > 0) {
            map.put("timeIn", inTime);
        }
        if (outTime > 0) {
            map.put("timeOut", outTime);
        }
        map.put("paral", false);
        map.put("adID", Constant.adid);
        map.put("gpsAdID", Constant.gpsAdid);
        map.put("altGPSAdID", Constant.adjustGpsAdid);
        map.put("androidVersion", BuildConfig.VERSION_NAME);
        map.put("deviceModel", Build.MODEL);
        return map;
    }
}
